const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');
module.exports = {
  entry: './app.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'main.js',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        // loader: 'babel-loader',
        use: [{
          loader: 'babel-loader',
          options: {
            "presets": ["@babel/preset-env"]
          }
        }]
      }
    ]
  },
  resolve: {
  },
  // 方便报错追踪
  devtool: 'source-map',
  plugins: [
  ],
  mode: 'production', // 下面的优化依赖于生产环境下
  optimization: {
    minimizer: [
      new TerserPlugin({
        sourceMap: true, // Must be set to true if using source-maps in production
        terserOptions: {
          compress: {
            drop_console: true,
            drop_debugger: true,
          },
        },
      }),
    ],
  },
};
